// app/controller/news.js
const Controller = require('egg').Controller;

class NewsController extends Controller {
  async list() {
    const dataList = {
      list: [
        { id: 1, title: 'this is news 1', url: '/news/1' },
        { id: 2, title: 'this is news 2', url: '/news/2' }
      ]
    };
    //await this.ctx.render('news/list.html', dataList);
    const ctx = this.ctx;
    const page = ctx.query.page || 1;
    const newsList = await ctx.service.news.list(page);
    const {data}=await ctx.service.user.query_id(1);
    //var d=await ctx.service.user.delete({name:'cd'});
    //console.log(d);
    await ctx.render('news/list.html', { list: newsList ,user:data});

  }
}

module.exports = NewsController;

